﻿using System;
using System.Collections.Generic;
using System.IO;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.LIB;
using YArchitech.Revit;
using YArchitech.Revit.RevitExtension;
using HYDragCurveJig;
using HYElectricKernel;
using HYElectricSystemDiagram.DataStruct;
using HYRElectric.PowerSystem;

namespace HYElectricSystemDiagram.TMethod
{
	internal class SystemDiagramDrawingHouse
	{
        public SystemDiagramDrawingHouse(XYZ point, ExternalCommandData cmdData, int viewScale, Autodesk.Revit.DB.Color switchLegendColor, GraphicsStyle frameStyle, GraphicsStyle midLineStyle, GraphicsStyle thickStyle, GraphicsStyle fineStyle, GraphicsStyle tableThickStyle, GraphicsStyle tableFineStyle, TextNoteType textNoteType, ElectricBoxData _elecBox, UserControlData2 _UserControl)
		{
			this.m_Revit = cmdData;
			this.m_ViewScale = viewScale;
			this.m_SwitchLegendColor = switchLegendColor;
			this.m_Doc = this.m_Revit.Application.ActiveUIDocument.Document;
			this.m_frameStyle = frameStyle;
			this.m_midLineStyle = midLineStyle;
			this.m_thickStyle = thickStyle;
			this.m_fineStyle = fineStyle;
			this.m_tableThickStyle = tableThickStyle;
			this.m_tableFineStyle = tableFineStyle;
			this.m_TextNoteType = textNoteType;
			this.BasePoint = point;
			this.elecBox = _elecBox;
			this.LoopSpace = 1500.0;
			this.nCount = this.elecBox.Loops.Count;
			this.userData = _UserControl;
			this.E_EleMach = this.elecBox.Box;
			this.TidyUptheData(this.userData, this.elecBox);
			this.m_GeneratrixLength = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace + 4000.0);
			if (this.nCount < 5)
			{
				this.m_GeneratrixLength = AssistFunc.mmToFeet(11000.0);
			}
			XYZ vector = new XYZ(0.0, -this.m_GeneratrixLength * 0.5, 0.0);
			this.transformMove = RevitVersionFuncs.CreateTranslation(vector);
		}

		private void TidyUptheData(UserControlData2 userDataH, ElectricBoxData elecBoxH)
		{
			string text = elecBoxH.Box.GetParameter("配电盘名称").AsString();
			string text2 = elecBoxH.Box.GetParameter("功率").AsValueString();
			double num = 0.0;
			if (text2.Contains("W"))
			{
				text2 = text2.Replace(" W", "");
			}
			num = double.Parse(text2);
			num /= 1000.0;
			if (string.IsNullOrEmpty(text))
			{
				text = "";
			}
			this.lstInTxt.Add(text);
			foreach (LineSettingInHouse lineSettingInHouse in userDataH.m_LineSettingInHouse)
			{
				if (lineSettingInHouse.dBoxPower == num)
				{
					this.m_LineSettingInHouse = lineSettingInHouse;
					break;
				}
			}
			if (this.m_LineSettingInHouse == null)
			{
				foreach (LineSettingInHouse lineSettingInHouse2 in userDataH.m_LineSettingInHouse)
				{
					if (lineSettingInHouse2.dBoxPower > num)
					{
						this.m_LineSettingInHouse = lineSettingInHouse2;
						break;
					}
				}
			}
			if (this.m_LineSettingInHouse == null)
			{
				this.m_LineSettingInHouse = userDataH.m_LineSettingInHouse[userDataH.m_LineSettingInHouse.Count - 1];
			}
			this.lstInTxt.Add(num + "kW");
			string item = "Pn=" + num + "kW";
			this.lstInTxt.Add(item);
			this.lstInTxt.Add("Cosφ=" + userDataH.dCos.ToString());
			this.lstInTxt.Add("Kx=" + userDataH.dKx.ToString());
			this.lstInTxt.Add("Pc=" + num * userDataH.dKx + "kW");
			if (this.m_LineSettingInHouse.strMonophase.Contains("单相"))
			{
				double num2 = Math.Round(num * userDataH.dKx / (0.22 * userDataH.dCos), 2);
				this.lstInTxt.Add("Ic=" + num2.ToString() + "A");
			}
			if (this.m_LineSettingInHouse.strMonophase.Contains("三相"))
			{
				double num3 = Math.Round(num * userDataH.dKx / (0.65817930685 * userDataH.dCos), 2);
				this.lstInTxt.Add("Ic=" + num3.ToString() + "A");
			}
			this.lstInTxt.Add("箱体尺寸:" + userDataH.strBoxSize);
			string text3 = this.E_EleMach.GetParameter("安装高度").AsDouble().ToString();
			string text4 = this.E_EleMach.GetParameter("安装方式").AsString();
			if (!string.IsNullOrEmpty(text3) && !string.IsNullOrEmpty(text4))
			{
				this.lstInTxt.Add(text4 + " , 底边距地" + text3 + "米");
				return;
			}
			if (string.IsNullOrEmpty(text3))
			{
				this.lstInTxt.Add(text4);
			}
			if (string.IsNullOrEmpty(text4))
			{
				this.lstInTxt.Add("底边距地" + text3 + "米");
			}
		}

		public bool DrawSystemDiagram(SystemGraphSet systemGraphSet)
		{
			List<LineSettingOutHouse> list = this.SortData(this.elecBox);
			this.nCount = list.Count;
			this.m_TextNoteHeight = AssistFunc.mmToFeet(systemGraphSet.TextHeight);
			this.CreateSystemDiagramIN();
			this.CreateSystemDiagramINTxt();
			this.CreateSystemDiagramOut(list);
			this.CreateDashFrame();
			this.MoveTransform();
			this.DrawModelSystemDiagram();
			return true;
		}

		private bool CreateSystemDiagramIN()
		{
			XYZ basePoint = this.BasePoint;
			XYZ xyz = new XYZ(basePoint.X - this.offset, basePoint.Y, basePoint.Z);
			XYZ xyz2 = new XYZ(basePoint.X + this.offset * 2.0, basePoint.Y, basePoint.Z);
			this.lstCurve.Add(Line.CreateBound(xyz, xyz2));
			XYZ xyz3 = new XYZ(xyz2.X + this.offset * 3.0, xyz2.Y, xyz2.Z);
			XYZ xyz4 = new XYZ(xyz3.X + this.offset * 2.0, xyz3.Y, xyz3.Z);
			this.lstCurve.Add(Line.CreateBound(xyz3, xyz4));
			XYZ xyz5 = new XYZ(xyz4.X + this.offset * 2.0, xyz4.Y, xyz4.Z);
			XYZ xyz6 = new XYZ(xyz5.X + this.offset * 2.0, xyz5.Y, xyz5.Z);
			this.lstCurve.Add(Line.CreateBound(xyz5, xyz6));
			this.lstInPoint.Add(xyz2);
			this.lstInPoint.Add(xyz4);
			double num = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace + 3000.0);
			XYZ xyz7 = new XYZ(basePoint.X + this.offset * 11.0, basePoint.Y + num / 2.0, basePoint.Z);
			XYZ xyz8 = new XYZ(basePoint.X + this.offset * 11.0, basePoint.Y - num / 2.0, basePoint.Z);
			this.lstMidCurve.Add(Line.CreateBound(xyz7, xyz8));
			XYZ origin = new XYZ(xyz2.X, xyz2.Y + this.offset + this.offset / 10.0, xyz2.Z);
			XYZ origin2 = new XYZ(xyz4.X - this.offset, xyz4.Y - this.offset - this.offset / 10.0, xyz4.Z);
			if (this.m_LineSettingInHouse != null)
			{
				this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, origin, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(this.m_LineSettingInHouse.strBreaker), this.m_LineSettingInHouse.strBreaker));
				this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, origin2, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(this.m_LineSettingInHouse.strTutamen), this.m_LineSettingInHouse.strTutamen));
			}
			return true;
		}

		private bool CreateSystemDiagramINTxt()
		{
			XYZ basePoint = this.BasePoint;
			List<XYZ> list = new List<XYZ>();
			double num = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace + 4000.0);
			if (this.nCount < 5)
			{
				num = AssistFunc.mmToFeet(9500.0);
			}
			num /= 2.0;
			list.Add(new XYZ(basePoint.X + this.offset, basePoint.Y + num - this.offset / 5.0 * 4.0 + this.offset / 10.0, basePoint.Z));
			this.lstCurveTxt.Add(Line.CreateBound(new XYZ(basePoint.X + this.offset / 2.0, basePoint.Y + num - this.offset / 5.0 * 8.0, basePoint.Z), new XYZ(basePoint.X + this.offset * 3.0, basePoint.Y + num - this.offset / 5.0 * 8.0, basePoint.Z)));
			list.Add(new XYZ(basePoint.X + this.offset, basePoint.Y + num - this.offset * 2.0 + this.offset / 5.0, basePoint.Z));
			list.Add(new XYZ(basePoint.X + this.offset, basePoint.Y + num - this.offset * 4.0 + this.offset / 5.0, basePoint.Z));
			list.Add(new XYZ(basePoint.X + this.offset, basePoint.Y + num - this.offset * 5.0 + this.offset / 5.0, basePoint.Z));
			list.Add(new XYZ(basePoint.X + this.offset, basePoint.Y + num - this.offset * 6.0 + this.offset / 5.0, basePoint.Z));
			list.Add(new XYZ(basePoint.X + this.offset, basePoint.Y + num - this.offset * 7.0 + this.offset / 5.0, basePoint.Z));
			list.Add(new XYZ(basePoint.X + this.offset, basePoint.Y + num - this.offset * 8.0 + this.offset / 5.0, basePoint.Z));
			num = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace + 4000.0);
			num /= 2.0;
			list.Add(new XYZ(basePoint.X + this.offset, basePoint.Y - num + this.offset * 2.0, basePoint.Z));
			list.Add(new XYZ(basePoint.X + this.offset, basePoint.Y - num + this.offset, basePoint.Z));
			int num2 = 0;
			foreach (string text in this.lstInTxt)
			{
				double textWidth = this.GetTextWidth(text);
				this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list[num2], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, textWidth, text));
				num2++;
			}
			return true;
		}

		private void CreateDashFrame()
		{
			XYZ basePoint = this.BasePoint;
			double num = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace + 4000.0);
			if (this.nCount < 5)
			{
				num = AssistFunc.mmToFeet(9500.0);
			}
			num /= 2.0;
			XYZ xyz = new XYZ(basePoint.X, basePoint.Y + num, basePoint.Z);
			XYZ xyz2 = new XYZ(basePoint.X + this.offset * 20.0, basePoint.Y + num, basePoint.Z);
			num = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace + 4000.0);
			num /= 2.0;
			XYZ xyz3 = new XYZ(basePoint.X, basePoint.Y - num, basePoint.Z);
			XYZ xyz4 = new XYZ(basePoint.X + this.offset * 20.0, basePoint.Y - num, basePoint.Z);
			this.lstDashCurve.Add(Line.CreateBound(xyz, xyz2));
			this.lstDashCurve.Add(Line.CreateBound(xyz2, xyz4));
			this.lstDashCurve.Add(Line.CreateBound(xyz4, xyz3));
			this.lstDashCurve.Add(Line.CreateBound(xyz3, xyz));
		}

		private bool CreateSystemDiagramOut(List<LineSettingOutHouse> lstLine)
		{
			XYZ basePoint = this.BasePoint;
			double num = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace);
			num /= 2.0;
			double num2 = AssistFunc.mmToFeet(this.LoopSpace);
			XYZ xyz = new XYZ(basePoint.X + this.offset * 11.0, basePoint.Y + num, basePoint.Z);
			XYZ xyz2 = new XYZ(basePoint.X + this.offset * 14.0, basePoint.Y + num, basePoint.Z);
			XYZ xyz3 = new XYZ(xyz2.X + this.offset * 3.0, xyz2.Y, xyz2.Z);
			XYZ xyz4 = new XYZ(xyz3.X + this.offset * 14.0, xyz3.Y, xyz3.Z);
			double num3 = AssistFunc.mmToFeet(400.0);
			int num4 = 1;
			int num5 = 1;
			for (int i = 0; i < this.nCount; i++)
			{
				XYZ xyz5 = xyz + num2 * (double)i * -XYZ.BasisY;
				XYZ xyz6 = xyz2 + num2 * (double)i * -XYZ.BasisY;
				XYZ xyz7 = xyz3 + num2 * (double)i * -XYZ.BasisY;
				XYZ xyz8 = xyz4 + num2 * (double)i * -XYZ.BasisY;
				this.lstCurve.Add(Line.CreateBound(xyz5, xyz6));
				this.lstCurve.Add(Line.CreateBound(xyz7, xyz8));
				XYZ origin = new XYZ(xyz5.X + num3, xyz5.Y + this.offset + this.offset / 10.0, xyz5.Z);
				if (this.m_LineSettingInHouse != null && this.m_LineSettingInHouse.strMonophase.Contains("三相"))
				{
					int num6 = i % 3;
					string text = "L" + (num6 + 1);
					this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, origin, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(text), text));
				}
				LineSettingOutHouse lineSettingOutHouse = lstLine[i];
				if (lineSettingOutHouse == null)
				{
					this.lstOutPoint.Add(xyz6);
				}
				else
				{
					if (lineSettingOutHouse.strLoopName.Equals("照明"))
					{
						this.lstOutPointGS.Add(xyz6);
					}
					else
					{
						this.lstOutPoint.Add(xyz6);
					}
					XYZ origin2 = new XYZ(xyz6.X, xyz6.Y + this.offset + this.offset / 10.0, xyz6.Z);
					this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, origin2, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(lineSettingOutHouse.strBreaker), lineSettingOutHouse.strBreaker));
					XYZ xyz9 = new XYZ(xyz7.X + this.offset * 4.0, xyz7.Y + this.offset + this.offset / 10.0, xyz7.Z);
					string text2;
					if (lineSettingOutHouse.strLoopName.Equals("照明"))
					{
						text2 = lineSettingOutHouse.strLoopNum + num4.ToString();
						num4++;
					}
					else
					{
						text2 = lineSettingOutHouse.strLoopNum + num5.ToString();
						num5++;
					}
					this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, xyz9, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(text2), text2));
					if (i < this.nCount - 1)
					{
						string text3 = string.Concat(new object[]
						{
							this.userData.strLineType,
							"-",
							lineSettingOutHouse.strLineSectionalArea,
							"  PC",
							lineSettingOutHouse.dPipeDiameter,
							"-",
							lineSettingOutHouse.strPerfunctoryWay
						});
						XYZ origin3 = xyz9 + XYZ.BasisX * this.offset * 2.0;
						this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, origin3, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(text3), text3));
					}
					XYZ origin4 = new XYZ(xyz8.X + this.offset, xyz8.Y + this.offset / 2.0, xyz8.Z);
					if (i == this.nCount - 1)
					{
						string text4 = "备用";
						this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, origin4, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(text4), text4));
					}
					else
					{
						this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, origin4, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(lineSettingOutHouse.strLoopName), lineSettingOutHouse.strLoopName));
					}
				}
			}
			return true;
		}

		private LineSettingOutHouse TidyUptheDataOut(List<Element> elems, string strLast = null)
		{
			LineSettingOutHouse result = null;
			if (strLast != null)
			{
				foreach (LineSettingOutHouse lineSettingOutHouse in this.userData.m_LineSettingOutHouse)
				{
					if (lineSettingOutHouse.strReadFamilyName == strLast)
					{
						result = lineSettingOutHouse;
						return result;
					}
				}
			}
			if (elems.Count == 0)
			{
				return null;
			}
			string name = (elems[0] as FamilyInstance).Symbol.Family.Name;
			foreach (LineSettingOutHouse lineSettingOutHouse2 in this.userData.m_LineSettingOutHouse)
			{
				if (name.Contains(lineSettingOutHouse2.strReadFamilyName))
				{
					result = lineSettingOutHouse2;
					return result;
				}
			}
			return result;
		}

		private List<LineSettingOutHouse> SortData(ElectricBoxData _elecBox)
		{
			List<LineSettingOutHouse> list = new List<LineSettingOutHouse>();
			List<LineSettingOutHouse> list2 = new List<LineSettingOutHouse>();
			foreach (HouseBoxLoopData houseBoxLoopData in _elecBox.Loops)
			{
				if (!houseBoxLoopData.UseName.Equals("备注"))
				{
					LineSettingOutHouse lineSettingOutHouse = this.TidyUptheDataOut(houseBoxLoopData.LoopDevs, null);
					if (lineSettingOutHouse != null)
					{
						list.Add(lineSettingOutHouse);
					}
					else
					{
						list2.Add(lineSettingOutHouse);
					}
				}
			}
			List<LineSettingOutHouse> list3 = new List<LineSettingOutHouse>();
			foreach (LineSettingOutHouse lineSettingOutHouse2 in this.userData.m_LineSettingOutHouse)
			{
				foreach (LineSettingOutHouse lineSettingOutHouse3 in list)
				{
					if (lineSettingOutHouse3.strLoopName == lineSettingOutHouse2.strLoopName)
					{
						list3.Add(lineSettingOutHouse3);
					}
				}
			}
			list3.Add(this.userData.m_LineSettingOutHouse[0]);
			return list3;
		}

		private bool DrawModelSystemDiagram()
		{
			Transaction transaction = new Transaction(this.m_Doc, "tr");
			try
			{
				transaction.Start();
				foreach (Curve curve in this.lstCurve)
				{
					this.DrawCurve(curve, this.m_thickStyle);
				}
				foreach (JigTextInfo textInfo in this.m_OtherTextInfos)
				{
					this.DrawTextNote(textInfo);
				}
				foreach (Curve curve2 in this.lstCurveTxt)
				{
					this.DrawCurve(curve2, this.m_fineStyle);
				}
				foreach (Curve curve3 in this.lstMidCurve)
				{
					this.DrawCurve(curve3, this.m_midLineStyle);
				}
				List<ElementId> list = new List<ElementId>();
				foreach (Curve curve4 in this.lstDashCurve)
				{
					DetailCurve detailCurve = this.DrawCurve(curve4, this.m_frameStyle);
					list.Add(detailCurve.Id);
				}
				LinePatternElement linePatternElementByName = LinePatternElement.GetLinePatternElementByName(this.m_Doc, "划线");
				if (linePatternElementByName == null)
				{
					linePatternElementByName = LinePatternElement.GetLinePatternElementByName(this.m_Doc, "Dash");
				}
				if (linePatternElementByName != null)
				{
					this.m_Doc.ActiveView.SetYJKProjLinePatternOverrideByElement(list, linePatternElementByName);
				}
				transaction.Commit();
				Transaction transaction2 = new Transaction(this.m_Doc, "tr");
				transaction2.Start();
				this.CreateInFamily();
				this.CreateOutFamily();
				transaction2.Commit();
			}
			catch (Exception)
			{
				transaction.RollBack();
				return false;
			}
			return true;
		}

		private void CreateInFamily()
		{
			this.CreateFamily("图例_断路器", this.lstInPoint[0]);
			this.CreateFamily("图例_自复式过欠压保护器", this.lstInPoint[1]);
		}

		private void CreateOutFamily()
		{
			for (int i = 0; i < this.lstOutPointGS.Count; i++)
			{
				this.CreateFamily("图例_断路器", this.lstOutPointGS[i]);
			}
			for (int j = 0; j < this.lstOutPoint.Count; j++)
			{
				this.CreateFamily("图例_带漏电保护的断路器", this.lstOutPoint[j]);
			}
		}

		private FamilySymbol GetFamilySymbol(Autodesk.Revit.DB.Document doc, string FamilyName)
		{
			FamilySymbol familySymbol = YJKRevitTools.GetFamilySymbol(FamilyName, doc);
			if (familySymbol != null)
			{
				return familySymbol;
			}
			string path = "SystemDiagram\\" + FamilyName + ".rfa";
			string text = Path.Combine(Product.FamilyLocation, RevitVersion.Version, path);
			if (!File.Exists(text))
			{
				return familySymbol;
			}
            doc.LoadFamilySymbol(text, FamilyName, out familySymbol);
			if (familySymbol != null && !familySymbol.IsActive)
			{
				familySymbol.Activate();
			}
			return familySymbol;
		}

		private AnnotationSymbol CreateFamily(string familyName, XYZ point)
		{
			XYZ basisX = XYZ.BasisX;
			point = JigGeometry.TransformPoint(point, this.transformMove);
			FamilySymbol familySymbol = this.GetFamilySymbol(this.m_Doc, familyName);
			if (familySymbol == null)
			{
				return null;
			}
			AnnotationSymbol annotationSymbol = this.m_Doc.Create.NewFamilyInstance(point, familySymbol, this.m_Doc.ActiveView) as AnnotationSymbol;
			if (basisX.IsAlmostEqualTo(XYZ.BasisX))
			{
				return annotationSymbol;
			}
			Line line = YJKLineEx.YJKGetUnBound(point, XYZ.BasisZ);
			if (!familyName.Contains("电动机"))
			{
				ElementTransformUtils.RotateElement(this.m_Doc, annotationSymbol.Id, line, -Math.PI*.5);
			}
			return annotationSymbol;
		}

		private void MoveTransform()
		{
			List<Curve> list = new List<Curve>();
			foreach (Curve c in this.lstCurve)
			{
				Curve item = this.TransformSelf(c, this.transformMove);
				list.Add(item);
			}
			this.lstCurve.Clear();
			this.lstCurve = list;
			List<Curve> list2 = new List<Curve>();
			foreach (Curve c2 in this.lstMidCurve)
			{
				list2.Add(this.TransformSelf(c2, this.transformMove));
			}
			this.lstMidCurve.Clear();
			this.lstMidCurve = list2;
			List<Curve> list3 = new List<Curve>();
			foreach (Curve c3 in this.lstDashCurve)
			{
				list3.Add(this.TransformSelf(c3, this.transformMove));
			}
			this.lstDashCurve.Clear();
			this.lstDashCurve = list3;
			for (int i = 0; i < this.m_BoxLineInfos.Count; i++)
			{
				this.m_BoxLineInfos[i].TransformSelf(this.transformMove);
			}
			for (int i = 0; i < this.m_OtherTextInfos.Count; i++)
			{
				this.m_OtherTextInfos[i].TransformSelf(this.transformMove, false);
			}
			List<Curve> list4 = new List<Curve>();
			foreach (Curve c4 in this.lstCurveTxt)
			{
				list4.Add(this.TransformSelf(c4, this.transformMove));
			}
			this.lstCurveTxt.Clear();
			this.lstCurveTxt = list4;
		}

		private Curve TransformSelf(Curve c, Transform matrix)
		{
			XYZ xyz = JigGeometry.TransformPoint(c.GetEndPoint(0), matrix);
			XYZ xyz2 = JigGeometry.TransformPoint(c.GetEndPoint(1), matrix);
			return Line.CreateBound(xyz, xyz2);
		}

		private DetailCurve DrawCurve(Curve curve, GraphicsStyle lineStyle)
		{
			DetailCurve result;
			try
			{
				Autodesk.Revit.DB.View activeView = this.m_Revit.Application.ActiveUIDocument.ActiveView;
				DetailCurve detailCurve = this.m_Revit.Application.ActiveUIDocument.Document.Create.NewDetailCurve(activeView, curve);
				if (detailCurve != null)
				{
					detailCurve.LineStyle = lineStyle;
				}
				result = detailCurve;
			}
			catch (Exception)
			{
				result = null;
			}
			return result;
		}

		private TextNote DrawTextNote(JigTextInfo textInfo)
		{
			if (textInfo.StrText.CompareTo("") == 0)
			{
				return null;
			}
			TextNote result;
			try
			{
				XYZ upVec = Geometry.RotateTo(textInfo.BaseVec, Math.PI*.5, XYZ.BasisZ);
				TextNote textNode = this.m_Doc.GetTextNode(this.m_Doc.ActiveView, textInfo.Origin, textInfo.BaseVec, upVec, textInfo.LineWidth, textInfo.TextAlign, textInfo.StrText);
				textNode.TextNoteType = textInfo.theTextNoteType;
				result = textNode;
			}
			catch (Exception)
			{
				result = null;
			}
			return result;
		}

		private double GetTextWidth(string str)
		{
			return (double)str.Length * this.m_TextNoteHeight * this.m_TextWHScale * 2.0;
		}

		private ExternalCommandData m_Revit;

		private Document m_Doc;

		private GraphicsStyle m_frameStyle;

		private GraphicsStyle m_midLineStyle;

		private GraphicsStyle m_thickStyle;

		private GraphicsStyle m_fineStyle;

		private GraphicsStyle m_tableThickStyle;

		private GraphicsStyle m_tableFineStyle;

		private TextNoteType m_TextNoteType;

		private List<JigEdgeInfo> m_CircuitLineInfos = new List<JigEdgeInfo>();

		private List<JigEdgeInfo> m_BoxLineInfos = new List<JigEdgeInfo>();

		private List<JigTextInfo> m_SystemInfoTextInfos = new List<JigTextInfo>();

		private List<JigTextInfo> m_OtherTextInfos = new List<JigTextInfo>();

		private double m_GeneratrixLength;

		private double m_TextNoteHeight;

		private double m_TextWHScale = 0.7;

		private int m_ViewScale;

        private Autodesk.Revit.DB.Color m_SwitchLegendColor;

		private List<Curve> lstCurve = new List<Curve>();

		private List<Curve> lstCurveTable = new List<Curve>();

		private List<Curve> lstCurveTxt = new List<Curve>();

		private List<Curve> lstMidCurve = new List<Curve>();

		private List<Curve> lstDashCurve = new List<Curve>();

		private double offset = AssistFunc.mmToFeet(500.0);

		private List<XYZ> lstInPoint = new List<XYZ>();

		private List<XYZ> lstOutPoint = new List<XYZ>();

		private List<XYZ> lstOutPointGS = new List<XYZ>();

		private List<List<XYZ>> lstlstOutTxt = new List<List<XYZ>>();

		private List<List<string>> lstlstOutTxtString = new List<List<string>>();

		private XYZ BasePoint = new XYZ(0.0, 0.0, 0.0);

		private List<FanPara> lstFan = new List<FanPara>();

		private List<XYZ> lstSurgePoint = new List<XYZ>();

		private Element E_EleMach;

		private List<JigTextInfo> m_TableTxt = new List<JigTextInfo>();

		private Transform transformMove;

		private ElectricBoxData elecBox;

		private double LoopSpace;

		private int nCount;

		private UserControlData2 userData;

		private List<string> lstInTxt = new List<string>();

		private LineSettingInHouse m_LineSettingInHouse;
	}
}
